<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />


</head>

<body>

    <div id="content">

        <dt class="u_i_form" style="text-align:center;background:#FAFAD2;height:85px;padding-top:6px;">请在这里进行支付宝绑定<br />若您还没有绑定支付宝，请您绑定<br />注意，请与实名认证信息保持一致！</dt>

        <dl class="" id="user_pass_box_form">
            <form id="myform">


            </form>
        </dl>

    </div>

</body>
<script id="interpolationtmpl" type="text/x-dot-template">
    <dd class="clear">

        <input type="text" name="name_attesta" id="name_attesta" value="{{=it.name}}" style="width:90%;height:55px;border:1px solid #ccc;margin-left:5%;text-align:center;margin-top:20px;margin-bottom:20px;background:buttonface;" disabled="disabled" />
    </dd>
    <dd class="clear">

        <input type="text" name="account" id="account" value="" style="width:90%;height:55px;border:1px solid #ccc;margin-left:5%;text-align:center;margin-top:20px;margin-bottom:20px;" placeholder="请输入支付宝账号" />

    </dd>
    <dd class="clear" style="text-align:right;padding:20px;color:red;" onclick="fnOpenWin();" >

        查看已绑定账号？
    </dd>


</script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="./conf/config.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript">
    apiready = function() {

        fnGetAlipayBind();
        initEventListenner(); //退出键添加提示框
        //fnGetAlipayBind
        // fnTryBind();


    };

    function fnGetAlipayBind() {

        var userInfo = $api.getStorage('userInfo');
        //获取数据app中存入的数据然后分配到模板中；
        var random = userInfo.random;
        var userid = userInfo.userid;

        api.ajax({
            url: SITE_URL+'index.php?m=api&c=appnew&a=get_userinfo&random=' + random + '&userid=' + userid,
            method: 'get',
        }, function(ret, err) {

            //$api.setStorage('userInfo',ret);

            if (ret.status == 1) {

                //把数据分配到模板
                fnUpdateAlipayBind(ret);
                //api.refreshHeaderLoadDone(); //下拉刷新隐藏
            } else {
                //alert(2222);
                api.openWin({
                    name: "login",
                    url: "login.html",
                    opaque: true,
                    vScrollBarEnabled: false
                });

            }
        });
    }

    function fnUpdateAlipayBind(ret) {

        var interText = doT.template($("#interpolationtmpl").text());
        $("#myform").html(interText(ret));

    }

    function initEventListenner() {

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.closeWin();
        });
    };

    function fnSubmitBindAlipyVal(){
        var userInfo = $api.getStorage('userInfo');
        var random = userInfo.random;
        var userid = userInfo.userid;
        //alert(random);
        var account = $api.byId('account').value;
        if (account == '') {
            alert('请输入支付宝账号');
            return false;
        };
        if (account != '') {
            api.ajax({
                url: SITE_URL+'index.php?m=api&c=appnew&a=bind_alipay_info',
                method: 'POST',
                data: {
                    values: {
                        "userid": userid,
                        "random": random,
                        "account": account
                    }
                }
            }, function(ret, err) {
var realName=$("#name_attesta").val();
                alert(ret.msg);
                api.openWin({
                    name: 'list_alipay_bind',
                    url: './list_alipay_bind.html',

                    pageParam: {
                      realName: realName
                    }
                });


            });

        }

    }
    function fnOpenWin(){

      var real_name=$("#name_attesta").val();


      api.openWin({
          name: 'list_alipay_bind',
          url: './list_alipay_bind.html',
          pageParam: {
              realName:real_name
          }
      });

    }

</script>

</html>
